import type { VNodeChild, Ref } from 'vue'
import type { ElInput, ElOption, ElSelect } from 'element-plus'

export interface BaseField<K> {
  key: K
  title: string | (() => VNodeChild)
}
export interface InputField<T> extends BaseField<T> {
  type: 'Input'
  props?: InstanceType<typeof ElInput>['$props']
}

interface IOptions {
  label: string
  value: any
  props?: InstanceType<typeof ElOption>['$props']
  [key: string]: any
}

export interface SelectField<T> extends BaseField<T> {
  type: 'Select'
  props?: InstanceType<typeof ElSelect>['$props']
  enums: IOptions[] | (() => VNodeChild) | Ref<IOptions[]>
}

export type QueryFormField<T> = InputField<T> | SelectField<T>
